<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page import="com.bosch.in.rtp1.ept.constant.ReleasedHoldColumnName"%>
<%@ page import="java.util.List"%>
<%@page import="com.bosch.in.rtp1.ept.constant.CommonConstants"%>
<script type="text/javascript" src="js/releasedhold.js"></script>
<script type="text/javascript" src="js/json2.js"></script>
<div id="filterHeader" class="ui-jqgrid ui-widget ui-corner-all">
	<div class = "ui-jqgrid-view">
		<div class="ui-jqgrid-titlebar ui-widget-header ui-corner-top ui-helper-clearfix">
			<a id="minFilterButton" class="ui-jqgrid-titlebar-close HeaderButton" href="javascript:void(0)" style="right: 0px;">
				<span id="minButton" class="ui-icon ui-icon-circle-triangle-n"></span>
			</a>
				<span class="ui-jqgrid-title">Filter Criteria</span>
		</div>
	</div>
</div>
<table id="filterCriteria" width="100%" border="0" class="box" id="search_box">
	<tbody>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td align="left" width='100px'>
				<input type="checkbox" id="department" name="department" value="EPT"  checked="checked"/>EPT <br>
				<input type="checkbox" id="department" name="department" value="EST1"  checked="checked"/>EST1 <br>
				<input type="checkbox" id="department" name="department" value="EST2"  checked="checked"/>EST2 <br>
			</td>
			<td>
			</td>
			<td>
			</td>
			<td  nowrap="nowrap" valign="top" colspan="2">
				<input type="checkbox" id="prodarea" name="prodarea" value="FAB1" checked="checked"/>FAB1 <br>
				<input type="checkbox" id="prodarea" name="prodarea" value="FAB2" checked="checked"/>FAB2 <br>
			</td>
			<td  width='90px' nowrap="nowrap" style="max-width: 90px;"> 
				<span style="width: 87px;display:inline-block;font-size: 11px;">Hold code</span>
				<span style="display:inline-block;font-size: 11px;">:</span>
			</td>
			<td width="120px" nowrap="nowrap"> 
				<html:select  name="releasedHoldCriteria" property="selectedHC" styleClass="DropDownTextBox" style="width:100%">
					<html:option value="">Select All</html:option>
					<html:optionsCollection name="releasedHoldCriteria" property="holdCodes" label="comment" value="patternsInStr"/>
				</html:select>
			</td>
			<td width="10px">
			</td>
			<td width="150px" nowrap="nowrap">
				<span style="width: 95%;display:inline-block;font-size: 11px;">Hold code reclassified </span>
				<span style="display:inline-block;font-size: 11px;">:</span>
			</td>
			
			<td width="120px" nowrap="nowrap"> 
				<html:select  name="releasedHoldCriteria" property="selectedHCReclass" styleClass="DropDownTextBox" style="width:100%">
					<html:option value="">Select All</html:option>
					<html:optionsCollection name="releasedHoldCriteria" property="holdCodesReclassified" label="comment" value="patternsInStr"/>
				</html:select>
			</td>
			<td width="10px"></td>
			<td></td>
		</tr>
		<tr>
			<td  width='100px' align="left" nowrap="nowrap">
				<span style="width: 100px;display:inline-block;font-size: 11px;">Customer name </span>
				<span style="display:inline-block;font-size: 11px;">:</span> 
			</td>
			<td width="120px">
				<input  name="customername" id="customername" style="width:100%"/>
			</td>
			<td width="10px">
			</td>
			<td  width="45px" nowrap="nowrap">
				<span style="width: 45px;display:inline-block;font-size: 11px;">Priority</span>
				<span style="display:inline-block;font-size: 11px;">:</span> 
			</td>
			
			<td width="240px" nowrap="nowrap">
				<span style="font-size: 11px;">
						  1 <input type="checkbox" id="priority" name="priority" value="1" checked="checked"/> &nbsp;&nbsp;
						  2	<input type="checkbox" id="priority" name="priority" value="2" checked="checked"/> &nbsp;&nbsp;
						  3	<input type="checkbox" id="priority" name="priority" value="3" checked="checked"/> &nbsp;&nbsp;
						  4	<input type="checkbox" id="priority" name="priority" value="4" /> &nbsp;&nbsp;
						  5	<input type="checkbox" id="priority" name="priority" value="5" />
				</span> 
			</td>
			<td width="90px" nowrap="nowrap">  
				<span style="width: 87px;display:inline-block;font-size: 11px;">Hold comment  </span>
				<span style="display:inline-block;font-size: 11px;">:</span>
			</td>
			
			<td width="120px" nowrap="nowrap"> 
				<input  name="holdcomment" id="holdcomment" style="width:100%"/>
			</td>
			<td width="10px">
			</td>
			<td width="150px" nowrap="nowrap">  
				<span style="width: 95%;display:inline-block;font-size: 11px;">Hold comment reclassified  </span>
				<span style="display:inline-block;font-size: 11px;">:</span>
			</td>
			
			<td width="120px" nowrap="nowrap"> 
				<input  name="holdcommentreclass" id="holdcommentreclass" style="width:100%"/>
			</td>
			<td></td>
			<td>
				
			</td>
		</tr>
		<tr style="height: 10px;"></tr>
		<tr>
			<td width="100px" align="left" nowrap="nowrap">
				<span style="width: 100px;display:inline-block;font-size: 11px;">Hold end from </span> 
				<span style="display:inline-block;font-size: 11px;">:</span>
			</td>
			
			<td width="120px" nowrap="nowrap"> 
				<input id="holdend_from_datepicker" size="13" type="text">
			</td>
			<td width="10px">
			</td>
			<td width="45px" nowrap="nowrap">
				<span style="width: 45px;display:inline-block;font-size: 11px;">to</span> 
				<span style="display:inline-block;font-size: 11px;">:</span>
			</td>
			
			<td width="120px" nowrap="nowrap"> 
				<input id="holdend_to_datepicker" size="13" type="text">
			</td>
			<td colspan="6"> 
			</td>
			
			<td nowrap="nowrap">
					<a class="boschBtnStd" href="javascript:searchReleasedHoldByFilter();">Show </a>
			</td>
		</tr>
	</tbody>
</table>

<br>
<div class="content">
<table id="s3list"></table>
<div id="s3pager"></div>
<div id="filter" style="margin-left: 30%; display: none">Search</div>

<jsp:useBean id="current" class="java.util.Date" />

<%
	List<String> frzCols = (List<String>) request.getAttribute(CommonConstants.RELEASED_HOLD_FRZ_COLS);
%>

<script type="text/javascript">
	$(function() {
		var startDate = new Date(<c:out value="${releasedHoldCriteria.holdEndFrom.year + 1900}"/>,
				<c:out value="${releasedHoldCriteria.holdEndFrom.month}"/>,
				<c:out value="${releasedHoldCriteria.holdEndFrom.date}"/>);

		$( "#holdend_from_datepicker" ).datepicker({
			showOn: "button",
			buttonImage: "images/calendar_blue2.png",
			buttonImageOnly: true,
			dateFormat: 'dd-M-yy'
			});
		
		$("#holdend_from_datepicker").datepicker("setDate", startDate);


		var endDate = new Date(<c:out value="${releasedHoldCriteria.holdEndTo.year + 1900}"/>,
				<c:out value="${releasedHoldCriteria.holdEndTo.month}"/>,
				<c:out value="${releasedHoldCriteria.holdEndTo.date}"/>);

		$( "#holdend_to_datepicker" ).datepicker({
			showOn: "button",
			buttonImage: "images/calendar_blue2.png",
			buttonImageOnly: true,
			dateFormat: 'dd-M-yy'
			}); 

		
		$("#holdend_to_datepicker").datepicker("setDate", endDate);
		
	});
	
	populateFinishedHoldData({
		colNames: [ 
		   			'<%=ReleasedHoldColumnName.LOT_ID%>', '<%=ReleasedHoldColumnName.HELD_DURATION%>',
		    		'<%=ReleasedHoldColumnName.TRACKIN_MAIN_QTY%>', '<%=ReleasedHoldColumnName.PART_ID%>',
					'<%=ReleasedHoldColumnName.LOT_TYPE%>', '<%=ReleasedHoldColumnName.CUSTOMER_NAME%>', 
					'<%=ReleasedHoldColumnName.PRIORITY%>', '<%=ReleasedHoldColumnName.PRO_AREA%>',
					'<%=ReleasedHoldColumnName.LOCATION%>', '<%=ReleasedHoldColumnName.STAGE%>',
					'<%=ReleasedHoldColumnName.RECIPE_ID%>', '<%=ReleasedHoldColumnName.RECIPE_TITLE%>',
					'<%=ReleasedHoldColumnName.HALT_START%>', '<%=ReleasedHoldColumnName.HALT_END%>', 
					'<%=ReleasedHoldColumnName.HOLD_CODE%>', '<%=ReleasedHoldColumnName.HOLD_COMMENT%>', 
					'<%=ReleasedHoldColumnName.RELEASED_COMMENT%>','<%=ReleasedHoldColumnName.HOLD_CODE_RECLASSIFIED%>',
					'<%=ReleasedHoldColumnName.HOLD_COMMENT_RECLASSIFIED%>'
					],
		colModel: [
					{
						name : '<%=ReleasedHoldColumnName.LOT_ID_DB%>',
						index : '<%=ReleasedHoldColumnName.LOT_ID_DB%>',
						width : 55,
						formatter:linkFormatter,
						unformat:linkUnFormatter,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.LOT_ID) ? "true": "false"%>
					},
					{
						name : '<%=ReleasedHoldColumnName.HELD_DURATION_DB%>',
						index : '<%=ReleasedHoldColumnName.HELD_DURATION_DB%>',
						width : 90,
						align : "right",
						sortable: true,
						sorttype: 'float',
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.HELD_DURATION) ? "true": "false"%>
					},
					{
						name : '<%=ReleasedHoldColumnName.TRACKIN_MAIN_QTY_DB%>',
						index : '<%=ReleasedHoldColumnName.TRACKIN_MAIN_QTY_DB%>',
						width : 40,
						align : "right",
						sortable: true,
						sorttype: 'int',
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.TRACKIN_MAIN_QTY) ? "true": "false"%>
						
					},
					{
						name : '<%=ReleasedHoldColumnName.PART_ID_DB%>',
						index : '<%=ReleasedHoldColumnName.PART_ID_DB%>',
						width : 100,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.PART_ID) ? "true": "false"%>
						
					},
					{
						name : '<%=ReleasedHoldColumnName.LOT_TYPE_DB%>',
						index : '<%=ReleasedHoldColumnName.LOT_TYPE_DB%>',
						width : 25,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.LOT_TYPE) ? "true": "false"%>
					},
					{
						name : '<%=ReleasedHoldColumnName.CUSTOMER_NAME_DB%>',
						index : '<%=ReleasedHoldColumnName.CUSTOMER_NAME_DB%>',
						width : 140,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.CUSTOMER_NAME) ? "true": "false"%>
						
					}, {
						name : '<%=ReleasedHoldColumnName.PRIORITY_DB%>',
						index : '<%=ReleasedHoldColumnName.PRIORITY_DB%>',
						width : 48,
						align : "right",
						sortable: true,
						sorttype: "int",
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.PRIORITY) ? "true": "false"%>
					}, {
						name : '<%=ReleasedHoldColumnName.PRO_AREA_DB%>',
						index : '<%=ReleasedHoldColumnName.PRO_AREA_DB%>',
						width : 25,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.PRO_AREA) ? "true": "false"%>
					}, 
					{
						name : '<%=ReleasedHoldColumnName.LOCATION_DB%>',
						index : '<%=ReleasedHoldColumnName.LOCATION_DB%>',
						width : 60,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.LOCATION) ? "true": "false"%>
					}, 
					{
						name : '<%=ReleasedHoldColumnName.STAGE_DB%>',
						index : '<%=ReleasedHoldColumnName.STAGE_DB%>',
						width : 70,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.STAGE) ? "true": "false"%>
					}, 
					{
						name : '<%=ReleasedHoldColumnName.RECIPE_ID_DB%>',
						index : '<%=ReleasedHoldColumnName.RECIPE_ID_DB%>',
						width : 55,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.RECIPE_ID) ? "true": "false"%>
					}, {
						name : '<%=ReleasedHoldColumnName.RECIPE_TITLE_DB%>',
						index : '<%=ReleasedHoldColumnName.RECIPE_TITLE_DB%>',
						width : 250,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.RECIPE_TITLE) ? "true": "false"%>
					},
					{
						name : '<%=ReleasedHoldColumnName.HALT_START_DB%>',
						index : '<%=ReleasedHoldColumnName.HALT_START_DB%>',
						width : 117,
						sorttype: 'date',
						formatter:'date',
						formatoptions : {srcformat:"d-M-Y H:i:s", newformat: "d-M-Y H:i:s"}, 
						searchoptions:{dataInit:function(el){
							$(el).width('');
							$(el).datepicker(
								{dateFormat:'dd-M-yy',
								 //changeYear: true,
							     //changeMonth: true,
							     showButtonPanel: true,
							     showOn: "button",
							     onSelect: function() {
								     if (this.id.substr(0, 3) === "gs_") {
								        // in case of searching toolbar
								     	setTimeout(function(){
								     		jQuery("#s3list")[0].triggerToolbar();
								        }, 50);
								     } else {
								     	// refresh the filter in case of
								     	// searching dialog
								        $(this).trigger('change');
								     }
							     }    	
								});
								setTimeout(function () {
									$(el).next('button.ui-datepicker-trigger').button({
										text: false,
										icons: {primary: 'ui-icon-calculator'}
									}).find('span.ui-button-text').css('padding', '0.1em'); 
								}, 100);
										
							},
							attr: {size: 13}

						},
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.HALT_START) ? "true": "false"%>
					},
					{
						name : '<%=ReleasedHoldColumnName.HALT_END_DB%>',
						index : '<%=ReleasedHoldColumnName.HALT_END_DB%>',
						width : 117,
						sorttype: 'date',
						formatter:'date',
						formatoptions : {srcformat:"d-M-Y H:i:s", newformat: "d-M-Y H:i:s"}, 
						searchoptions:{dataInit:function(el){
							$(el).width('');
							$(el).datepicker(
								{dateFormat:'dd-M-yy',
								 //changeYear: true,
							     //changeMonth: true,
							     showButtonPanel: true,
							     showOn: "button",
							     onSelect: function() {
								     if (this.id.substr(0, 3) === "gs_") {
								        // in case of searching toolbar
								     	setTimeout(function(){
								     		jQuery("#s3list")[0].triggerToolbar();
								        }, 50);
								     } else {
								     	// refresh the filter in case of
								     	// searching dialog
								        $(this).trigger('change');
								     }
							     }    	
								});
								setTimeout(function () {
									$(el).next('button.ui-datepicker-trigger').button({
										text: false,
										icons: {primary: 'ui-icon-calculator'}
									}).find('span.ui-button-text').css('padding', '0.1em'); 
								}, 100);
										
							},
							attr: {size: 13}

						},
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.HALT_END) ? "true": "false"%>
					},
					{
						name : '<%=ReleasedHoldColumnName.HOLD_CODE_DB%>',
						index : '<%=ReleasedHoldColumnName.HOLD_CODE_DB%>',
						width : 34,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.HOLD_CODE) ? "true": "false"%>
					}, 
					{
						name : '<%=ReleasedHoldColumnName.HOLD_COMMENT_DB%>',
						index : '<%=ReleasedHoldColumnName.HOLD_COMMENT_DB%>',
						width : 270,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.HOLD_COMMENT) ? "true": "false"%>
					},
					{
						name : '<%=ReleasedHoldColumnName.RELEASED_COMMENT_DB%>',
						index : '<%=ReleasedHoldColumnName.RELEASED_COMMENT_DB%>',
						width : 270,
						editable:false,
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.RELEASED_COMMENT) ? "true": "false"%>
					},
					{
						name : '<%=ReleasedHoldColumnName.HOLD_CODE_RECLASSIFIED_DB%>',
						index : '<%=ReleasedHoldColumnName.HOLD_CODE_RECLASSIFIED_DB%>',
						width : 100,
						editable:true,
						editoptions: { maxlength: 20},
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.HOLD_CODE_RECLASSIFIED) ? "true": "false"%>
					}, 
					{
						name : '<%=ReleasedHoldColumnName.HOLD_COMMENT_RECLASSIFIED_DB%>',
						index : '<%=ReleasedHoldColumnName.HOLD_COMMENT_RECLASSIFIED_DB%>',
						width : 270,
						editable:true,
						editoptions: { maxlength: 100},
						frozen : <%=frzCols.contains(ReleasedHoldColumnName.HOLD_COMMENT_RECLASSIFIED) ? "true": "false"%>
					}
					],
		//defaultSortColumn: '<%=ReleasedHoldColumnName.LOT_ID_DB%>',
		redColorCon: '<%=request.getAttribute(CommonConstants.RED_COLOR_CON)%>',
		yellowColorCon: '<%=request.getAttribute(CommonConstants.YELLOW_COLOR_CON)%>',
		currentDate: '<fmt:formatDate  pattern="dd-MMM-yyyy HH:mm:ss" value="${current}" />'
			}
	);
</script>
</div>
<div class="contextMenu" id="rightClickMenu" style="display:none">
    <ul>
			<li id="CopyRow">
                <span class="ui-icon ui-icon-plus" style="float:left"></span>
                <span style="font-size:11px; font-family:Verdana">Copy Data to Clipboard</span>
            </li>
   </ul>
</div>
<iframe style="width: 0px; height: 0px; visibility: hidden;" src="http://rt-fabigate:8777/iGate/dlz_lotid"></iframe>